/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vista;

import java.sql.ResultSet;
import javax.swing.JOptionPane;
import vista.modelo.OperacionesVarias;

/**
 *
 * @author caesar
 */
public class iFrmCambiarClave extends javax.swing.JInternalFrame {
    //clases.ClsUsuario clsUsuario = new clases.ClsUsuario();

    String backOldUsuario = null;//para respaldar el usuario anterior en caso de ser cambiado

    /**
     * Creates new form iFrmCambiarClave
     */
    public iFrmCambiarClave() {
        initComponents();
        OperacionesVarias.cerrarVentanaEscape(this);
        chkCambiar.setVisible(false);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        btnCerrar = new javax.swing.JButton();
        btnAplicar = new javax.swing.JButton();
        pnlId = new javax.swing.JPanel();
        lblNombre = new javax.swing.JLabel();
        lblCedula = new javax.swing.JLabel();
        lbltxtCedula = new javax.swing.JLabel();
        lbltxtNombre = new javax.swing.JLabel();
        pnlAut = new javax.swing.JPanel();
        txtUsuario = new javax.swing.JTextField();
        txtClave = new javax.swing.JPasswordField();
        jLabel2 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        btnValidar = new javax.swing.JButton();
        pnlCambiar = new javax.swing.JPanel();
        lblConfirmar = new javax.swing.JLabel();
        txtConfirmarClave = new javax.swing.JPasswordField();
        txtClaveNueva = new javax.swing.JPasswordField();
        lblClaveNueva = new javax.swing.JLabel();
        txtNewUsuario = new javax.swing.JTextField();
        lblNewUsr = new javax.swing.JLabel();
        chkCambiar = new javax.swing.JCheckBox();
        separadorUsr = new javax.swing.JSeparator();

        setTitle("Cambiar clave de usuario");
        setVisible(true);

        btnCerrar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/jpgs/agt_home.png"))); // NOI18N
        btnCerrar.setText("Cerrar");
        btnCerrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCerrarActionPerformed(evt);
            }
        });

        btnAplicar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/jpgs/accept.png"))); // NOI18N
        btnAplicar.setText("Aplicar");
        btnAplicar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAplicarActionPerformed(evt);
            }
        });

        pnlId.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.TOP));

        lblNombre.setFont(new java.awt.Font("Ubuntu", 0, 14)); // NOI18N
        lblNombre.setForeground(new java.awt.Color(114, 27, 27));
        lblNombre.setText("Nombres:");

        lblCedula.setFont(new java.awt.Font("Ubuntu", 0, 14)); // NOI18N
        lblCedula.setForeground(new java.awt.Color(114, 27, 27));
        lblCedula.setText("Cédula:");

        lbltxtCedula.setForeground(new java.awt.Color(1, 153, 0));
        lbltxtCedula.setText("   ");

        lbltxtNombre.setForeground(new java.awt.Color(1, 153, 0));
        lbltxtNombre.setText("   ");

        javax.swing.GroupLayout pnlIdLayout = new javax.swing.GroupLayout(pnlId);
        pnlId.setLayout(pnlIdLayout);
        pnlIdLayout.setHorizontalGroup(
            pnlIdLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlIdLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlIdLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblCedula)
                    .addComponent(lblNombre))
                .addGap(18, 18, 18)
                .addGroup(pnlIdLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lbltxtNombre, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbltxtCedula, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        pnlIdLayout.setVerticalGroup(
            pnlIdLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlIdLayout.createSequentialGroup()
                .addGroup(pnlIdLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblCedula)
                    .addComponent(lbltxtCedula))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlIdLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbltxtNombre)
                    .addComponent(lblNombre))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pnlAut.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED), "Ingrese el nombre de usuario y contraseña actuales:", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.TOP, new java.awt.Font("Dialog", 0, 12), java.awt.SystemColor.activeCaption)); // NOI18N

        jLabel2.setFont(new java.awt.Font("Ubuntu", 0, 14)); // NOI18N
        jLabel2.setText("Contraseña:");

        jLabel1.setFont(new java.awt.Font("Ubuntu", 0, 14)); // NOI18N
        jLabel1.setText("Usuario:");

        btnValidar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/jpgs/refresh.png"))); // NOI18N
        btnValidar.setText("Validar");
        btnValidar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnValidarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnlAutLayout = new javax.swing.GroupLayout(pnlAut);
        pnlAut.setLayout(pnlAutLayout);
        pnlAutLayout.setHorizontalGroup(
            pnlAutLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlAutLayout.createSequentialGroup()
                .addGap(22, 22, 22)
                .addGroup(pnlAutLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(pnlAutLayout.createSequentialGroup()
                        .addGroup(pnlAutLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(pnlAutLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(txtUsuario, javax.swing.GroupLayout.DEFAULT_SIZE, 256, Short.MAX_VALUE)
                            .addComponent(txtClave)))
                    .addComponent(btnValidar, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        pnlAutLayout.setVerticalGroup(
            pnlAutLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlAutLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlAutLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(txtUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlAutLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2)
                    .addComponent(txtClave, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnValidar)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pnlCambiar.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Ingrese la nueva contraseña y su confirmación:", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", 0, 12), java.awt.SystemColor.activeCaption)); // NOI18N

        lblConfirmar.setFont(new java.awt.Font("Ubuntu", 0, 13)); // NOI18N
        lblConfirmar.setText("Confirmacion:");

        lblClaveNueva.setFont(new java.awt.Font("Ubuntu", 0, 13)); // NOI18N
        lblClaveNueva.setText("Contrasena:");

        txtNewUsuario.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        txtNewUsuario.setEnabled(false);

        lblNewUsr.setFont(new java.awt.Font("Ubuntu", 0, 13)); // NOI18N
        lblNewUsr.setText("Usuario:");

        chkCambiar.setFont(new java.awt.Font("Ubuntu", 0, 13)); // NOI18N
        chkCambiar.setText("Cambiar");
        chkCambiar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chkCambiarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnlCambiarLayout = new javax.swing.GroupLayout(pnlCambiar);
        pnlCambiar.setLayout(pnlCambiarLayout);
        pnlCambiarLayout.setHorizontalGroup(
            pnlCambiarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(separadorUsr)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlCambiarLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlCambiarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlCambiarLayout.createSequentialGroup()
                        .addComponent(lblNewUsr)
                        .addGap(45, 45, 45)
                        .addComponent(txtNewUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, 203, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(chkCambiar))
                    .addGroup(pnlCambiarLayout.createSequentialGroup()
                        .addGroup(pnlCambiarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblConfirmar)
                            .addComponent(lblClaveNueva))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(pnlCambiarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(txtConfirmarClave, javax.swing.GroupLayout.DEFAULT_SIZE, 261, Short.MAX_VALUE)
                            .addComponent(txtClaveNueva))))
                .addContainerGap())
        );
        pnlCambiarLayout.setVerticalGroup(
            pnlCambiarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlCambiarLayout.createSequentialGroup()
                .addGap(11, 11, 11)
                .addGroup(pnlCambiarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtNewUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblNewUsr)
                    .addComponent(chkCambiar))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(separadorUsr, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlCambiarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtClaveNueva, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblClaveNueva))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlCambiarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblConfirmar)
                    .addComponent(txtConfirmarClave, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(17, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(btnAplicar, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(btnCerrar, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(pnlAut, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(pnlId, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(pnlCambiar, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 402, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(pnlAut, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(pnlId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(pnlCambiar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnAplicar)
                    .addComponent(btnCerrar))
                .addContainerGap(53, Short.MAX_VALUE))
        );

        getAccessibleContext().setAccessibleParent(this);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnCerrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCerrarActionPerformed
        this.dispose();
    }//GEN-LAST:event_btnCerrarActionPerformed

    private void btnValidarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnValidarActionPerformed
        ResultSet rs = null;
        try {
            if (txtUsuario.getText().trim().compareTo("") != 0) {

                rs = null;//clsUsuario.selectUsuario(txtUsuario.getText().trim(),txtClave.getText().trim());

                if (rs != null) {
                    txtUsuario.setText("");
                    txtClave.setText("");
                    lbltxtCedula.setText(rs.getString("cedula"));
                    lbltxtNombre.setText(rs.getString("nombre") + " " + rs.getString("apellido"));
                    txtNewUsuario.setText(rs.getString("usuario"));
                    backOldUsuario = rs.getString("usuario");
                    txtNewUsuario.setEnabled(false);
                    chkCambiar.setVisible(true);
                    chkCambiar.setSelected(false);
                } else {
                    lbltxtCedula.setText("".trim());
                    lbltxtNombre.setText("".trim());
                    txtNewUsuario.setText("".trim());
                    txtClaveNueva.setText("".trim());
                    txtConfirmarClave.setText("".trim());
                    backOldUsuario = null;
                    txtNewUsuario.setEnabled(false);
                    chkCambiar.setVisible(false);
                    JOptionPane.showMessageDialog(null, "Nombre de usuario y/o clave son incorrectos ...", "Validación de usuario", JOptionPane.WARNING_MESSAGE);
                    txtUsuario.setText("");
                    txtClave.setText("");
                    txtClaveNueva.setText("");
                    txtConfirmarClave.setText("");
                }
            } else {
                JOptionPane.showMessageDialog(null, "Ingrese su nombre de usuario con su contraseña para poder validar ...", "Validacion de usuario", JOptionPane.WARNING_MESSAGE);
                return;
            }

        } catch (Exception ex) {
            ex.getMessage();
        }
    }//GEN-LAST:event_btnValidarActionPerformed

    private void btnAplicarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAplicarActionPerformed
        try {
            if (lbltxtCedula.getText().trim().compareTo("") == 0) {
                JOptionPane.showMessageDialog(null, "Primero debe validar el nombre de usuario y contraseña", "Aplicar", JOptionPane.WARNING_MESSAGE);
                return;
            }
            if (chkCambiar.isSelected()) {
                if (txtNewUsuario.getText().trim().length() != 0) {
                    if (txtClaveNueva.getText().trim().length() == 0 && txtConfirmarClave.getText().trim().length() == 0) {
                        if (JOptionPane.showConfirmDialog(null, "Ha dejado la contraseña en blanco.\nPor seguridad se recomienda usar contraseña.\n\nAún así desea continuar?", "Aplicar", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == 0) {
                            //if(clsUsuario).updateClave(lbltxtCedula.getText().trim(), txtNewUsuario.getText().trim(), txtClaveNueva.getText().trim()) == 1)
                            int a = 0;
                            if (a == 0) {
                                txtClave.setText("");
                                txtClaveNueva.setText("");
                                txtConfirmarClave.setText("");
                                chkCambiar.setSelected(false);
                                txtNewUsuario.setEnabled(false);
                                JOptionPane.showMessageDialog(null, "El cambio de contraseña se realizó correctamente\ny su nuevo nombre de usuario es: \" " + txtNewUsuario.getText().trim() + " \"", "Aplicar", JOptionPane.INFORMATION_MESSAGE);
                            }
                        }
                    } else if (txtConfirmarClave.getText().trim().compareTo(txtClaveNueva.getText().trim()) == 0) {
                        //if(clsUsuario.updateClave(lbltxtCedula.getText().trim(), txtNewUsuario.getText().trim(), txtClaveNueva.getText().trim()) == 1)
                        int a = 0;
                        if (a == 0) {
                            txtClave.setText("");
                            txtClaveNueva.setText("");
                            txtConfirmarClave.setText("");
                            chkCambiar.setSelected(false);
                            txtNewUsuario.setEnabled(false);
                            JOptionPane.showMessageDialog(null, "El cambio de contraseña se realizó correctamente\ny su nuevo nombre de usuario es: \" " + txtNewUsuario.getText().trim() + " \"", "Aplicar", JOptionPane.INFORMATION_MESSAGE);
                        }
                    } else {
                        JOptionPane.showMessageDialog(null, "La nueva contraseña y su confirmación no coinciden \n" + "Corrija estos campos para poder continuar", "Aplicar", JOptionPane.WARNING_MESSAGE);
                    }

                } else//
                {
                    JOptionPane.showMessageDialog(null, "El nuevo nombre de usuario no puede estar vacio", "Aplicar", JOptionPane.WARNING_MESSAGE);
                }
            } else//chk
            {
                if (txtClaveNueva.getText().trim().length() == 0 && txtConfirmarClave.getText().trim().length() == 0) {
                    if (JOptionPane.showConfirmDialog(null, "Ha dejado la contraseña en blanco.\nPor seguridad se recomienda usar contraseña.\n\nAún así desea continuar?", "Aplicar", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == 0) {
                        //if(clsUsuario.updateClave(lbltxtCedula.getText().trim(), txtNewUsuario.getText().trim(), txtClaveNueva.getText().trim()) == 1)
                        int a = 0;
                        if (a == 0) {
                            txtClave.setText("");
                            txtClaveNueva.setText("");
                            txtConfirmarClave.setText("");
                            chkCambiar.setSelected(false);
                            txtNewUsuario.setEnabled(false);
                            JOptionPane.showMessageDialog(null, "El cambio de contraseña se realizó correctamente", "Aplicar", JOptionPane.INFORMATION_MESSAGE);
                        }
                    }
                } else if (txtConfirmarClave.getText().trim().compareTo(txtClaveNueva.getText().trim()) == 0) {
                    //if(clsUsuario.updateClave(lbltxtCedula.getText().trim(), txtNewUsuario.getText().trim(), txtClaveNueva.getText().trim()) == 1)
                    int a = 0;
                    if (a == 0) {
                        txtClave.setText("");
                        txtClaveNueva.setText("");
                        txtConfirmarClave.setText("");
                        chkCambiar.setSelected(false);
                        txtNewUsuario.setEnabled(false);
                        JOptionPane.showMessageDialog(null, "El cambio de contraseña se realizó correctamente", "Aplicar", JOptionPane.INFORMATION_MESSAGE);
                    }
                } else {
                    JOptionPane.showMessageDialog(null, "La nueva contraseña y su confirmación no coinciden \n" + "Corrija estos campos para poder continuar", "Aplicar", JOptionPane.WARNING_MESSAGE);
                }
            }
        } catch (Exception ex) {
            ex.getMessage();
        }
    }//GEN-LAST:event_btnAplicarActionPerformed

    private void chkCambiarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkCambiarActionPerformed
        if (chkCambiar.isSelected()) {
            txtNewUsuario.setEnabled(true);
        } else {
            txtNewUsuario.setEnabled(false);
            txtNewUsuario.setText(backOldUsuario);
        }
    }//GEN-LAST:event_chkCambiarActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAplicar;
    private javax.swing.JButton btnCerrar;
    private javax.swing.JButton btnValidar;
    private javax.swing.JCheckBox chkCambiar;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel lblCedula;
    private javax.swing.JLabel lblClaveNueva;
    private javax.swing.JLabel lblConfirmar;
    private javax.swing.JLabel lblNewUsr;
    private javax.swing.JLabel lblNombre;
    private javax.swing.JLabel lbltxtCedula;
    private javax.swing.JLabel lbltxtNombre;
    private javax.swing.JPanel pnlAut;
    private javax.swing.JPanel pnlCambiar;
    private javax.swing.JPanel pnlId;
    private javax.swing.JSeparator separadorUsr;
    private javax.swing.JPasswordField txtClave;
    private javax.swing.JPasswordField txtClaveNueva;
    private javax.swing.JPasswordField txtConfirmarClave;
    private javax.swing.JTextField txtNewUsuario;
    private javax.swing.JTextField txtUsuario;
    // End of variables declaration//GEN-END:variables
}
